<template>
    <div class="my-filter">
        <div :class="{active: flag === item.name }" v-for="item in labels" :key="item" @click="changeFilter(item)">
            {{item.name}}
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            labels: [{
                name: '全部',
                flag: ''
            }, {
                name: '已完成',
                flag: true
            }, {
                name: '未完成',
                flag: false
            }],
            flag: '全部'
        }
    },
    methods: {
        changeFilter(item) {
            this.flag = item.name
            this.$emit('changeFilter', item)
        }
    },
}
</script>

<style scoped>
.my-filter {
    display: flex;
    margin-top: 10px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}
.my-filter div {
    margin-right: 10px;
    cursor: pointer;
}
.my-filter div.active,
.my-filter div:hover {
    color: #67c23a;
}
</style>